package com.lipaluma.excel.xml.configuration;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang.BooleanUtils;

import com.lipaluma.excel.config.ExcelExtension;
import com.lipaluma.xml.configuration.XmlConfiguration;

@XmlRootElement(name="excel-config")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlExcelConfiguration implements XmlConfiguration {
	@XmlAttribute(name="has-header")
	private Boolean hasHeader;
	@XmlAttribute(name="header-line")
	private Integer headerLine;
	@XmlAttribute(name="map-columns-by-headers")
	private Boolean mapColumnsByHeaders;
	@XmlAttribute(name="nb-lines-header")
	private Integer nbLinesHeader;
	@XmlAttribute(name="write-header")
	private Boolean writeHeader;
	
	@XmlAttribute(name="sheet-name")
	private String sheetName;
	@XmlAttribute(name="sheet-index")
	private Integer sheetIndex;
	@XmlAttribute(required=true)
	private ExcelExtension extension;
	
	public boolean hasHeader() {
		return BooleanUtils.toBoolean(hasHeader);
	}
	public Integer getHeaderLine() {
		if(headerLine == null)
			return 1;
		return headerLine;
	}
	public boolean mapColumnsByHeaders() {
		return BooleanUtils.toBoolean(mapColumnsByHeaders);
	}
	public Integer getNbLinesHeader() {
		if(nbLinesHeader == null)
			return 1;
		return nbLinesHeader;
	}
	public boolean writeHeader() {
		return BooleanUtils.toBoolean(writeHeader);
	}
	public String getSheetName() {
		return sheetName;
	}
	public Integer getSheetIndex() {
		return sheetIndex;
	}
	public ExcelExtension getExtension() {
		return extension;
	}
}
